package com.eva.framework.rbac.session;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

@Data
@Schema(description = "会话配置")
@Configuration
@ConfigurationProperties(prefix = "app.session", ignoreInvalidFields = true)
public class SessionProperties {

    @Schema(description = "会话超时时间")
    private Integer expire;

    @Schema(description = "token在缓存中的存储前缀")
    private String tokenCachePrefix;

    @Schema(description = "会话模式")
    private SessionMode mode;

    @Schema(description = "拦截器配置")
    private Interceptor interceptor;

    @Data
    @Schema(description = "会话拦截配置")
    public static class Interceptor {

        @Schema(description = "拦截路径")
        private String[] pathPatterns;

        @Schema(description = "排除拦截路径")
        private String[] excludePathPatterns;
    }

    /**
     * 会话模式
     */
    public enum SessionMode {

        /**
         * 交互式，存在交互时自动延长会话过期时长
         */
        INTERACTIVE,

        /**
         * 固定会话时长
         */
        FIXED
    }
}
